<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <title>Home</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/ready.css">
    <link rel="stylesheet" href="assets/css/demo.css">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="assets/layer/layer/theme/default/layer.css"/>
    <link rel="stylesheet" href="angularjs/pagination.css">
    <script src="../homePage/js/jquery-1.9.1/jquery.js"></script>
    <script src="bootstrap/js/bootstrap.js"></script>
    <script src="layer/layer.js"></script>
    <script src="angularjs/angular.min.js"></script>
    <script src="angularjs/pagination.js"></script>
</head>

<script>
    var app = angular.module("myApp", ['pagination']);
    app.controller("myCtrl", function ($scope, $http) {
        let admin = sessionStorage.getItem("admin");
        $scope.secondid = JSON.parse(admin).userid;
        $scope.username = JSON.parse(admin).username;
        // $scope.secondid = 1;

        $scope.paginationConf = {
            currentPage: 1,//当前页
            totalItems: 500,//总数
            itemsPerPage: 8,//每页个数
            perPageOptions: [8, 10, 20, 50, 100],//分页选项
            onChange: function () {//当更改页码时，自动触发事件
                // $scope.search($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
                $scope.getCondition($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
            }
        };


        //查看已通过查勘的所有申请
        $scope.getLossAssessment = function () {
            $http.get("http://localhost:9001/report/getLossAssessment").success(function (data) {
                if (data.code == 0) {
                    $scope.list = data.data.rows;
                    $scope.message = "";
                } else if (data.code == 404) {
                    $scope.list = data.data.rows;
                    $scope.message = "暂时没有数据";
                }
            });
        };
        //初始化分页
        $scope.search = function (pageIndex, pageSize) {
            $http.get("http://localhost:9001/report/getLossAssessment1?pageIndex=" + pageIndex + "&pageSize=" + pageSize)
                .success(function (data) {
                    if (data.code == 0) {
                        $scope.list = data.data.rows;
                        $scope.paginationConf.totalItems = data.data.total;
                        $scope.message = "";
                    } else if (data.code == 404) {
                        $scope.list = data.data.rows;
                        $scope.message = "暂时没有数据";
                    }
                });
        }
        //定损条件查询
        $scope.reportstate = '待定损';
        $scope.getCondition = function (pageIndex, pageSize) {
            var tReport = {
                reportid: $scope.reportid,
                reporttime: $scope.reporttime,
                policynum: $scope.policynum,
                reportstate: $scope.reportstate
            };
            $http.post("http://localhost:9001/report/condition?pageIndex=" + pageIndex + "&pageSize=" + pageSize, tReport)
                .success(function (data) {
                    if (data.code == 0) {
                        $scope.list = data.data.rows;
                        $scope.paginationConf.totalItems = data.data.total;
                        $scope.message = "";
                    } else if (data.code == 404) {
                        $scope.list = data.data.rows;
                        $scope.message = "暂时没有数据";
                    }
                });
        };
        $scope.getCondition2 = function () {
            // alert("111");
            //调用上面的方法；
                $scope.getCondition(1, $scope.paginationConf.itemsPerPage);
        };
        //查看报案详情
        $scope.getReportDetails = function (reportid) {
            $("#myModal").modal("show");
            $http.get("http://localhost:9001/report/getReportDetails?reportid=" + reportid).success(function (data) {
                if (data.code == 0) {
                    $scope.details = data.data;
                } else if (data.code == -1) {
                    layer.msg(data.msg);
                }
            });
        };
        //打开审批模态框
        $scope.approve = function (reportid) {
            $("#myModal1").modal("show");
            $("#myModal").modal("hide");
            $scope.reportid = reportid;
        };
        //关闭模态框
        $scope.hide = function () {
            $("#myModal1").modal("hide");
            layer.msg("取消审批")
            $scope.reportid = '';
            $scope.secondid = '';
            $scope.money = '';
            $scope.damageclasses = '';
            $scope.remark = '';
        }
        //定损
        $scope.update = function () {
            var tReport = {
                reportid: $scope.reportid,
                secondid: $scope.secondid,
                money: $scope.money,
                reportstate: $scope.reportstate,
                damageclasses: $scope.damageclasses,
                remark: $scope.remark,
            };
            $http.post("http://localhost:9001/report/updateLossAssessment", tReport).success(function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg);

                } else if (data.code == 101) {
                    layer.msg(data.msg);

                } else if (data.code == -1) {
                    layer.msg(data.msg);
                }
                //关闭模态框 ，把输入框清空
                $("#myModal1").modal("hide");
                $scope.reportid = '';
                $scope.secondid = '';
                $scope.money = '';
                $scope.reportstate = '待定损';
                $scope.damageclasses = '';
                $scope.remark = '';
                $scope.getLossAssessment();
            });
        };
    });
    //退出登陆
    function quiet() {
        sessionStorage.clear();
        window.location.href = "../adminLogin/login.html";
    }
</script>

<body ng-app="myApp" ng-controller="myCtrl" ng-init="getLossAssessment()">
<div class="wrapper">
    <div class="main-header">
        <div class="logo-header">
            <a href="index.html" class="logo">
                <img src="../pay/img/logo.png" style="height: 40px;width: 100px"> 定损部
            </a>
            <button class="navbar-toggler sidenav-toggler ml-auto" type="button" data-toggle="collapse"
                    data-target="collapse"
                    aria-controls="sidebar" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <button class="topbar-toggler more"><i class="la la-ellipsis-v"></i></button>
        </div>
        <nav class="navbar navbar-header navbar-expand-lg" style="float: right;margin-bottom: 0px !important;">
            <div class="container-fluid">
                <ul class="navbar-nav topbar-nav ml-md-auto align-items-center">


                    <li class="nav-item dropdown">
                        <a class="dropdown-toggle profile-pic" data-toggle="dropdown" href="#" aria-expanded="false">
                            <tbody id="theuser">{{username}}</tbody>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li>
                                <div class="user-box">

                                    <div class="u-text">
                                        <h4>{{username}}</h4>
                                        <p class="text-muted"></p>
                                        <a onclick="quiet()" class="btn btn-rounded btn-danger btn-sm">退出登录</a>
                                    </div>
                                </div>
                            </li>

                        </ul>
                        <!-- /.dropdown-user -->
                    </li>
                </ul>
            </div>
        </nav>
    </div>
    <div class="sidebar">
        <div class="scrollbar-inner sidebar-wrapper">
            <ul class="nav">
                <li class="nav-item">
                    <a href="home.html">
                        <i class="la la-dashboard"></i>
                        <p>待勘查报案单</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
                <li class="nav-item active">
                    <a href="lossAssessment.html">
                        <i class="la la-fonticons"></i>
                        <p>案件定损</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
            </ul>
        </div>
    </div>
    <div class="main-panel">
        <div class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-12">

                        <div class="card">
                            <div class="card-header panel-info">
                                <h4 class="card-title">报案单定损处理</h4>
                            </div>
                            <div class="card-body">
                                <form>
                                    报案号 &nbsp;&nbsp;&nbsp;<input ng-model="reportid"
                                                                 placeholder="报案号"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    报案时间 &nbsp;&nbsp;&nbsp;<input ng-model="reporttime"
                                                                  placeholder="2020-09-29"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    保单号 <input ng-model="policynum"
                                               placeholder="保单号"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    状态 &nbsp;&nbsp;&nbsp;<select ng-model="reportstate" style="height: 27px">
                                    <option value="待定损">待定损</option>
                                    <option value="定损通过">定损通过</option>
                                    <option value="定损驳回">定损驳回</option>
                                </select>&nbsp;&nbsp;&nbsp;
                                    <button style="margin-left: 35px;height: 30px" class="btn btn-info btn-sm"
                                            type="button"
                                            ng-click="getCondition2()">查询
                                    </button>
                                </form>
                                <table class="table table-bordered table-hover table-striped text-center">
                                    <tr>
                                        <td>序号</td>
                                        <td>报案号</td>
                                        <td>保单号</td>
                                        <td>报案人</td>
                                        <td>报案时间</td>
                                        <td>勘察人员id</td>
                                        <td>处理状态</td>
                                        <td>操作</td>
                                    </tr>
                                    <tr ng-repeat="l in list">
                                        <td ng-bind="$index+1"></td>
                                        <td>{{l.reportid}}</td>
                                        <td>{{l.policynum}}</td>
                                        <td>{{l.tUser.username}}</td>
                                        <td>{{l.reporttime | date:'yyyy-MM-dd'}}</td>
                                        <td>{{l.surveyorid}}</td>
                                        <td>{{l.reportstate}}</td>
                                        <td>
                                            <button class="btn btn-info btn-sm" ng-click="getReportDetails(l.reportid)">
                                                审批
                                            </button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="8">
                                            <span style="font-size:25px;color: #8c8c8c;text-align: center"> {{message}}</span></br>
                                            <!--自动分页的标签！！！-->
                                            <span style="height: 10px;text-align: center"
                                                  class="pagination pagination-centered">
                                                        <tm-pagination style="position: relative;top:-31px"
                                                                       conf="paginationConf"></tm-pagination>
                                        </span>
                                        </td>
                                    </tr>
                                </table>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="margin-top: 150px">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">查看详情</h4>
            </div>
            <div class="modal-body">
                <div>
                    报案号：{{details.reportid}}</br>
                    保单详情:</br>
                    &nbsp; &nbsp; &nbsp;保单号&nbsp;&nbsp;{{details.tPolicy.policyno}}</br>
                    &nbsp; &nbsp; &nbsp;被保人姓名&nbsp;&nbsp;{{details.tPolicy.insuredpersonname}}</br>
                    &nbsp; &nbsp; &nbsp;保险状态&nbsp;&nbsp;<d ng-if="details.tPolicy.safestate==0">已过期</d>
                    <d ng-if="details.tPolicy.safestate==1">正在生效</d>
                    </br>
                    报案项目：{{details.tSafetypeitem.description}}</br>
                    定损项目：{{details.tSafetypeitem.description}}</br>
                    受理时间：{{details.lastmodifytime| date:'yyyy-MM-dd'}}</br>
                    损失类别：
                    <d ng-if="details.damageclasses==1">微损</d>
                    <d ng-if="details.damageclasses==2">一般</d>
                    <d ng-if="details.damageclasses==3">严重</d>
                    </br>
                    状态：{{details.reportstate}}</br>
                    备注：{{details.remark}}</br>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-info" ng-click="approve(details.reportid)">审批</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <div class="modal-dialog" style="margin-top: 150px">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel1">审批</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" ng-model="reportid"/>
                <input type="hidden" ng-model="secondid"/>
                </br>
                </br>
                &nbsp;&nbsp;定损金额&nbsp;&nbsp;&nbsp;<input ng-model="money" style="width: 300px;height: 25px"/></br></br>
                &nbsp;&nbsp;审批状态&nbsp;&nbsp;&nbsp;<select ng-model="reportstate" style="width: 300px;height: 25px">
                <option value="定损通过">定损通过</option>
                <option value="定损驳回">定损驳回</option>
            </select>
                </br>
                </br>
                &nbsp;&nbsp;损失等级&nbsp;&nbsp;&nbsp;<select ng-model="damageclasses" style="width: 300px;height: 25px">
                <option value=""></option>
                <option value="1">微损</option>
                <option value="2">一般</option>
                <option value="3">严重</option>
            </select>
                </br>
                </br>
                &nbsp;&nbsp;备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注
                &nbsp;&nbsp;&nbsp;<input ng-model="remark" style="width: 300px;height: 25px"/></br></br>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" ng-click="hide()">关闭</button>
                <button type="button" class="btn btn-info" ng-click="update()">提交更改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</body>
<script src="assets/js/core/jquery.3.2.1.min.js"></script>
<script src="assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
<script src="assets/js/core/popper.min.js"></script>
<script src="assets/js/core/bootstrap.min.js"></script>
<script src="assets/js/plugin/chartist/chartist.min.js"></script>
<script src="assets/js/plugin/chartist/plugin/chartist-plugin-tooltip.min.js"></script>
<script src="assets/js/plugin/bootstrap-notify/bootstrap-notify.min.js"></script>
<script src="assets/js/plugin/bootstrap-toggle/bootstrap-toggle.min.js"></script>
<script src="assets/js/plugin/jquery-mapael/jquery.mapael.min.js"></script>
<script src="assets/js/plugin/jquery-mapael/maps/world_countries.min.js"></script>
<script src="assets/js/plugin/chart-circle/circles.min.js"></script>
<script src="assets/js/plugin/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script src="assets/js/ready.min.js"></script>
<!--<script src="assets/js/demo.js"></script>-->
</html>
